package net.yunxinyong.cec.controller;

import net.yunxinyong.cec.entity.Cec711SixFinanceDebt;
import net.yunxinyong.cec.service.Cec711SixDebtService;
import net.yunxinyong.cec.utils.CECResult;
import net.yunxinyong.cec.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 李跃
 * @@date
 */
@RequestMapping("711six")
@RestController
public class Cec711SixController  {
    @Autowired
    private Cec711SixDebtService cec711SixDebtService;

    @PostMapping(value = "add")
    public CECResult addSix(@RequestBody Cec711SixFinanceDebt cec711SixFinanceDebt){
        Cec711SixFinanceDebt cec711SixFinanceDebt1 = cec711SixDebtService.insertSixDebt(cec711SixFinanceDebt);
        if(cec711SixFinanceDebt1 == null){
            return CECResult.build(500,"企业信息已存在");
        }
        return CECResult.build(200,"企业信息添加成功");
    }

    @GetMapping(value = "delete")
    public CECResult deleteSix(@RequestParam(value = "id") Integer id){
        int i = cec711SixDebtService.deleteSixDebt(id);
        if(i > 0){
            return CECResult.build(200,"删除企业信息成功");
        }
        return CECResult.build(500,"删除企业信息失败");
    }

    @PostMapping(value = "update")
    public CECResult updateSix(@RequestBody Cec711SixFinanceDebt cec711SixFinanceDebt){
        int i = cec711SixDebtService.updateSixDebt(cec711SixFinanceDebt);
        if(i > 0){
            return CECResult.build(200,"企业信息更新成功");
        }
        return CECResult.build(500,"企业信息更新失败");
    }

    @GetMapping(value = "get/{page}/{rows}")
    public CECResult getSix(@RequestBody Cec711SixFinanceDebt cec711SixFinanceDebt,@PathVariable int page,@PathVariable int rows){
        PageBean pageBean = cec711SixDebtService.ListSixDebt(cec711SixFinanceDebt, page, rows);
        if(pageBean.getPageDatas().isEmpty()){
            return CECResult.build(500,"没有查询到企业信息",pageBean);
        }
        return CECResult.build(200,"查询到了企业信息",pageBean);

    }
}
